home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / thor / calcdl.thor < prev    next >
Text File  |  1996-11-10  |  3KB  |  102 lines

  1. /*
  2. ** $VER: CalcDl.thor 1.2 (18.10.96)
  3. ** by Eirik Nicolai Synnes
  4. **
  5. ** This script will calculate an estimate of the time needed to download
  6. ** files selected in Thor and present the results in a requester.  In
  7. ** order to do this the files will have to be present in Thor's file
  8. ** database.  It can be run either in the Startup Window or from inside a
  9. ** system.
  10. **
  11. ** Change the cpsrate variable below to whatever your modem is capable of.
  12. **
  13. */
  14.  
  15. cpsrate = 3100
  16.  
  17. /*
  18. ** Don't edit anything below here
  19. */
  20.  
  21. options results
  22.  
  23. /* Find Thor and BBSREAD ARexx ports' */
  24. p=address()||' '||show('P',,);if pos(' THOR.',p)>0 then thorport=word(substr(p,pos(' THOR.',p)),1);else do;say 'No THOR port found!';exit(0);end
  25. if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
  26.  
  27. totsize = 0; numfiles = 0; notfound = 0
  28.  
  29. address(thorport)
  30. 'CURRENTSYSTEM STEM 'curbbs
  31. if rc > 1 then do
  32.     'REQUESTNOTIFY "CURRENTSYSTEM: 'THOR.LASTERROR'" "Ok"'
  33.     exit(0)
  34.     end
  35.  
  36. address(bbsread)
  37. 'GETBBSDATA BBSNAME "'curbbs.BBSNAME'" STEM 'bbsdata
  38. if rc ~= 0 then do 
  39.     address(thorport)
  40.     'REQUESTNOTIFY "GETBBSDATA: 'BBSREAD.LASTERROR'" "Ok"'
  41.     exit(0)
  42.     end
  43.  
  44. if bbsdata.NUMEVENT > 0 then do event = bbsdata.FIRSTEVENT to bbsdata.LASTEVENT
  45.     'READBREVENT BBSNAME "'curbbs.BBSNAME'" EVENTNR 'event' TAGSSTEM 'evtag' DATASTEM 'evdata
  46.     if rc ~= 0 then do
  47.         address(thorport)
  48.         'REQUESTNOTIFY "READBREVENT: 'BBSREAD.LASTERROR'" "Ok"'
  49.         exit(0)
  50.         end
  51.  
  52.     if evdata.EVENTTYPE = 4 then do
  53.         if ~bittst(evdata.FLAGS, 0) & ~bittst(evdata.FLAGS, 2) & ~bittst(evdata.FLAGS, 3) & ~bittst(evdata.FLAGS, 5) then do
  54.             if evtag.DIRECTORY = 'EVTAG.DIRECTORY' then 'SEARCHBRFILE BBSNAME "'curbbs.BBSNAME'" STEM 'file' SEARCH "'evtag.FILENAME'" NAME'
  55.             else do
  56.                 'SEARCHBRFILE BBSNAME "'curbbs.BBSNAME'" STEM 'file' FAREANAME "'evtag.DIRECTORY'" SEARCH "'evtag.FILENAME'" NAME'
  57.                 end
  58.             if (rc ~= 0) & (rc ~= 6) then do
  59.                 address(thorport)
  60.                 'REQUESTNOTIFY "SEARCHBRFILE: 'BBSREAD.LASTERROR'" "Ok"'
  61.                 exit(0)
  62.                 end
  63.             if (symbol('result') = 'VAR') & (result > 0) then do
  64.                 'READBRFILE BBSNAME "'curbbs.BBSNAME'" FAREANAME "'file.FILEAREA.1'" FILENR 'file.FILE.1.1' TAGSSTEM 'fltag
  65.                 if rc ~= 0 then do
  66.                     address(thorport)
  67.                     'REQUESTNOTIFY "READBRFILE: 'BBSREAD.LASTERROR'" "Ok"'
  68.                     address(bbsread)
  69.                     notfound = notfound + 1
  70.                     end
  71.                 else do
  72.                     totsize = totsize + fltag.SIZE
  73.                     numfiles = numfiles + 1
  74.                     end
  75.                 end
  76.             else notfound = notfound + 1
  77.             end
  78.         end
  79.     drop evtag. evdata. file.
  80.     end
  81.  
  82. address(thorport)
  83.  
  84. if totsize = 0 & notfound = 0 then do
  85.     'REQUESTNOTIFY "No active downloads on 'curbbs.BBSNAME'." "Ok"'
  86.     exit(0)
  87.     end
  88.  
  89. if totsize > 0 then do
  90.     xfertime = totsize / 8 * 9 / cpsrate
  91.     xfermin = trunc(xfertime / 60)
  92.     xfersec = trunc(xfertime // 60)
  93.     reqbody = 'Statistics on active downloads at 'curbbs.BBSNAME':\n\n'numfiles 'files counting 'totsize' bytes ('totsize/1024'kb).\n\nTransfertime at 'cpsrate' characters per second:\nApproximately 'xfermin' minute(s) and 'xfersec' second(s).'
  94.     if notfound > 0 then reqbody = reqbody'\n\n'notfound' file(s) were not found in the file database.'
  95.     end
  96. else do
  97.     if notfound > 0 then reqbody = 'None of the files were found in the file database.'
  98.     end
  99.  
  100. 'REQUESTNOTIFY "'reqbody'" "Thanks"'
  101. exit(0)
  102.